package com.doge.util.auth;

import com.doge.bean.pojo.admin.Admin;
import com.doge.bean.pojo.user.User;
import org.apache.shiro.SecurityUtils;

/**
 * @program: doge
 * @description:
 * @author: Keyu Li
 * @create: 2021-12-02 17:03
 **/


public class GetSubject {
    public static Integer getAdminId(){
        Admin admin = (Admin) SecurityUtils.getSubject().getPrincipal();
        return admin.getId();
    }

    public static Integer getUserId(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        return user.getId();
    }

    public static User getUser(){
        return (User) SecurityUtils.getSubject().getPrincipal();
    }

    public static Admin getAdmin(){
        return (Admin) SecurityUtils.getSubject().getPrincipal();
    }

    public static String getIp(){
        return SecurityUtils.getSubject().getSession().getHost();
    }

}
